package API.Collection.Set.HashSet.LinkedHashSet;

import java.util.HashSet;
import java.util.Set;

public class Test {
    public static void main(String[] args) {
        Set<Student> set = new HashSet<>();
        Student s1 = new Student("Jack", 18, "2023001");
        Student s2 = new Student("Nick", 19, "2023002");
        Student s3 = new Student("John", 20, "2023003");
        Student s4 = new Student("Jack", 18, "2023001");
        set.add(s1);
        set.add(s2);
        set.add(s3);
        set.add(s4);
        // 输出的顺序与传入一样，因为LinkedHashSet在HashSet的基础上，新增了双向链表
        for (Student student : set) {
            System.out.println(student);
        }
    }
}
